﻿var fs = require('fs'); // 引入fs模块
/**
 * Created by 斗酒 on 2018/1/16.
cron:01,30 8-12 * * *
 */
var request = require('request');
const path = require('path')
const os = require('os')
//const fs = require('fs');
var url2="https://edu.seewo.com/api/v1/auth/login";
var url="https://edu.seewo.com/api/v2/task/log";
var requestData0={"username": "15779752720", "password": "f87ac9c543fe7bf64428a19a16f73148", "captcha": null};
var requestData={"taskId":3,"param":"30"};
var requestData1={"taskId":5,"param":""};
var requestData2={"taskId":4,"param":""};
var requestData3={"taskId":2,"param":""};
var c="x-auth-token=";


var abc=fs.readFileSync("./a.txt",'utf8');
var xyz=abc.toString()
console.log(xyz)
var d="'";
var s3 = "";
headers1={'X-APM-TraceId': 'e27d22632d78458b9c608962906f4323','x-auth-app': 'EasiNote5', 'x-auth-brand': '','x-auth-timestamp': '1640592280149','x-auth-sign': '0fc0330b8f8cbcf5668e08a0e6eb965c16f343a873ab832f3a8abd52f14bc870','Content-Type': 'application/json;charset=utf-8','Host': 'edu.seewo.com','Cookie':fs.readFileSync("./a.txt",'utf8') ,'Content-Length': '25'};
console.log(headers1)
httprequest0(url2,requestData0);
httprequest(url,requestData);
httprequest1(url,requestData1);
httprequest2(url,requestData2);
httprequest3(url,requestData3);




function httprequest0(url,data){
    global.a = "33"
    request({
        url: url2,
        method: "POST",
        json: true,
        headers: {
        'X-APM-TraceId': '7775fecac4d64a108ae998be637e0bab',
        'Content-Type': 'application/json;charset=utf-8',
        'Host': 'edu.seewo.com',
        'Cookie': 'client_channel=seewo; x-auth-app=EasiNote5; x-auth-token=',
        'Content-Length': '87',

        },
        body: requestData0
    }, function(error, response, body) {
        if (!error && response.statusCode == 200) {
            a=body.data.token;
            //console.log(d+c+a+d);
            // 请求成功的处理逻辑
            var lst = [c+a,'x-auth-app=EasiNote5', 'x-auth-brand=', 'client_version=5.2.1.9634', 'client_build_version=89634', 'client_flags=tabs'];
            global.s1 = lst.join(";");
            global.s2 = d +s1 +d;
            s3=s1;
            //console.log(s2);
            
 
// 如果当前木目录下没有这个写入内容的文件，那么系统会自动帮我们创建
fs.writeFile('./a.txt', s3, (err, writeOfContent) => {
    try {
        console.log(writeOfContent); // undefined
    } catch (e) {
        console.log('写入内容失败', e)
    }
})


        }
    });
}
function httprequest(url,data){
    request({
        url: url,
        method: "POST",
        json: true,
        headers: headers1,

        body: requestData

    }, function(error, response, body) {
        if (!error && response.statusCode == 200) {
            console.log(body)
           // console.log(request.headers)
            // 请求成功的处理逻辑
        }
    });
}

function httprequest1(url,data){
    request({
        url: url,
        method: "POST",
        json: true,
        headers: {
            'X-APM-TraceId': '4f9125b956d142839768fe5c71ef9d3b',
            'x-auth-app': 'EasiNote5',
            'x-auth-brand': '',
            'x-auth-timestamp': '1640585186375',
            'x-auth-sign': '6a5a4437035056b2ebdd7cb0c290283ca83d517b029571f6ba2fbbfe10d8bb2c',
            'Content-Type': 'application/json;charset=utf-8',
            'Host': 'edu.seewo.com',
            'Cookie': fs.readFileSync("./a.txt",'utf8'),
            'Content-Length': '23',


        },
        body: requestData1
    }, function(error, response, body) {
        if (!error && response.statusCode == 200) {
            console.log(body)
            // 请求成功的处理逻辑
        }
    });
};

function httprequest2(url,data){
    request({
        url: url,
        method: "POST",
        json: true,
        headers: {
            'X-APM-TraceId': '1fdab8a8f4fa47239ee33c86c78d1e89',
            'x-auth-app': 'EasiNote5',
            'x-auth-brand': '',
            'x-auth-timestamp': '1640415901113',
            'x-auth-sign': '55f7ad42386f1ed896565a9c084978d374d8183a6694f8a0723fee7428e23974',
            'Content-Type': 'application/json;charset=utf-8',
            'Host': 'edu.seewo.com',
            'Cookie': fs.readFileSync("./a.txt",'utf8'),
            'Content-Length': '23',
        },
        body: requestData2
    }, function(error, response, body) {
        if (!error && response.statusCode == 200) {
            console.log(body)
            // 请求成功的处理逻辑
        }
    });
};

function httprequest3(url,data){
    request({
        url: url,
        method: "POST",
        json: true,
        headers: {
            'X-APM-TraceId': '2eaa41c3ee1e4131b6f4a94a583451e4',
            'x-auth-app': 'EasiNote5',
            'x-auth-brand': '',
            'x-auth-timestamp': '1640413511534',
            'x-auth-sign': '440d3d5c1f6e6881d42da1e3afac7596cf49c5cb2bfaee383bd430453252a2f3',
            'Content-Type': 'application/json;charset=utf-8',
            'Host': 'edu.seewo.com',
            'Cookie': fs.readFileSync("./a.txt",'utf8'),
            'Content-Length': '23',

        },
        body: requestData3
    }, function(error, response, body) {
        if (!error && response.statusCode == 200) {
            console.log(body)
            // 请求成功的处理逻辑
        }
    });
};

 
